package com.example.springbootvalidated.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.*;
import java.time.LocalDateTime;
/**
 * Created by IntelliJ IDEA2022.3.2
 * @Author: Tenghw
 * @Date: 2023/05/04  19:29
 * @Description:
 */
@Data
public class User {
    private Long id;
    @NotBlank(message = "名称不能为空")
    @Length(min = 2, max = 10, message = "名称长度必须在2到10个字符之间")
    private String userName;
    @NotBlank(message = "密码不能为空")
    @Length(min = 3, max = 10, message = "密码长度3~10位")
    private String password;
    @NotBlank(message = "邮箱不能为空")
    @Email(message = "邮箱格式不正确")
    private String emaill;
    /**
     * 0：女生；1：男生
     */
    @Min(value = 0, message = "最小值为0")
    @Max(value = 1, message = "最大值为1")
    private Integer sex;

    @Future
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    private LocalDateTime createtime;
}
